package com.huya.controller.admin;

import com.huya.common.result.Result;
import com.huya.pojo.vo.ReportDataVO;
import com.huya.pojo.vo.UserDataVO;
import com.huya.service.DataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@RestController
@RequestMapping("/admin/data")
@Slf4j
public class DataController {

    @Autowired
    private DataService dataService;

    /**
     * 用户数据统计
     * @param begin
     * @param end
     * @return
     */
    @GetMapping("/userData")
    public Result<UserDataVO> userData(
            @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
            @DateTimeFormat(pattern = "yyyy-MM-dd")  LocalDate end) {
        log.info("begin:{}, end:{}", begin, end);
        return Result.success(dataService.getUserData(begin, end));
    }

    /**
     * 举报信数据统计
     * @param begin
     * @param end
     * @return
     */
    @GetMapping("/reportData")
    public Result<ReportDataVO> reportData(
            @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
            @DateTimeFormat(pattern = "yyyy-MM-dd")  LocalDate end) {
        log.info("begin:{}, end:{}", begin, end);
        return Result.success(dataService.getReportData(begin, end));
    }
}
